function varargout = ESTACIONESDEDESCARGA(varargin)
% ESTACIONESDEDESCARGA MATLAB code for ESTACIONESDEDESCARGA.fig
%      ESTACIONESDEDESCARGA, by itself, creates a new ESTACIONESDEDESCARGA or raises the existing
%      singleton*.
%
%      H = ESTACIONESDEDESCARGA returns the handle to a new ESTACIONESDEDESCARGA or the handle to
%      the existing singleton*.
%
%      ESTACIONESDEDESCARGA('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in ESTACIONESDEDESCARGA.M with the given input arguments.
%
%      ESTACIONESDEDESCARGA('Property','Value',...) creates a new ESTACIONESDEDESCARGA or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before ESTACIONESDEDESCARGA_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to ESTACIONESDEDESCARGA_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help ESTACIONESDEDESCARGA

% Last Modified by GUIDE v2.5 18-Nov-2014 11:20:16

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @ESTACIONESDEDESCARGA_OpeningFcn, ...
                   'gui_OutputFcn',  @ESTACIONESDEDESCARGA_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before ESTACIONESDEDESCARGA is made visible.
function ESTACIONESDEDESCARGA_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to ESTACIONESDEDESCARGA (see VARARGIN)

% Choose default command line output for ESTACIONESDEDESCARGA
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes ESTACIONESDEDESCARGA wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = ESTACIONESDEDESCARGA_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on button press in conectar.
function conectar_Callback(hObject, eventdata, handles)
% hObject    handle to conectar (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

global obj;
    obj=serial('COM7');
    set(obj,'BaudRate',9600);
    set(obj,'DataBits',8);
    set(obj,'Parity','none');
    set(obj,'StopBits',1);
    set(obj,'FlowControl','none');
    fopen(obj);
% --- Executes on button press in desconectar.
function desconectar_Callback(hObject, eventdata, handles)
% hObject    handle to desconectar (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global obj;
    fclose(obj);
    delete(obj)
    clear 
    delete(instrfind({'Port'},{'COM1'}))

% --- Executes on button press in bomba1.
function bomba1_Callback(hObject, eventdata, handles)
% hObject    handle to bomba1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global obj;
    fprintf(obj, '%s', 'L');


% --- Executes on button press in bomba2.
function bomba2_Callback(hObject, eventdata, handles)
% hObject    handle to bomba2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global obj;
    fprintf(obj, '%s', 'S');
    
   
% --- Executes on button press in bomba3.
function bomba3_Callback(hObject, eventdata, handles)
% hObject    handle to bomba3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global obj;
    fprintf(obj, '%s', 'K');
    


% --- Executes on button press in bomba4.
function bomba4_Callback(hObject, eventdata, handles)
% hObject    handle to bomba4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global obj;
    fprintf(obj, '%s', 'Q');


% --- Executes on button press in bomba5.
function bomba5_Callback(hObject, eventdata, handles)
% hObject    handle to bomba5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global obj;
    fprintf(obj, '%s', 'R');


% --- Executes on button press in bomba6.
function bomba6_Callback(hObject, eventdata, handles)
% hObject    handle to bomba6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global obj;
    fprintf(obj, '%s', 'C');


% --- Executes on button press in salida.
function salida_Callback(hObject, eventdata, handles)
% hObject    handle to salida (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global obj;
    fprintf(obj, '%s', 'H');


% --- Executes during object creation, after setting all properties.
function axes5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to axes5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: place code in OpeningFcn to populate axes5
